import java.io.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024-10-05
 * Time: 12:33
 */
public class IODemo12 {
    public static void main(String[] args) {
        try(Reader reader= new FileReader("./test.txt")){
            //Reader和Writer的字符流与OutputStream和InputStream相似
            while(true){
                char[] buffer = new char[1024];
                int n = reader.read(buffer);
                if (n == -1){
                    break;
                }
                String s = new String(buffer , 0 , n);
                System.out.println(s);
                /*
                for (int i = 0; i < n; i++) {
                    System.out.print(buffer[i]);
                    System.out.print("  ");
                }*/
            }

        } catch (IOException e) {
            throw new RuntimeException(e);
         }
    }
}
